<script>

/*	json 
	
	1. 缺点
		- 无法判断正则
		- 无法判断函数
		- 时间对象结果不唯一
*/	
function diff1(obj1, obj2) {
	let json1 = JSON.stringify(obj1);
	let json2 = JSON.stringify(obj2);
	return json1 === json2;
}

/* 	递归	*/
function diff(obj1, obj2) {
	if(typeof(obj1) != 'object') return obj1 === obj2;
	let res = true;
	for(let key in obj1) {
		if(obj2[key]) {
			if(typeof(obj1[key] === 'object')) {
				res = diff(obj1[key], obj2[key])
			}
		} else {
			return false;
		}
	}
	return res;
}

let obj1 = {
	b: { a: {a: '1'}},
	a:[1,3,4,{a:['1']}]
}
let obj2 = {
	a: [1,3,4,{a: ['1']}],
	b: { a: {a: '1'}}
}
let res = diff(obj1, obj2);
console.log(res);

</script>